<template>
    <div class="changepass">
            <h4>密码修改</h4>
        <div><span>请输入旧密码:</span><input type="text" minlength="8" maxlength="16" v-model="oldpassword"></div>
        <div><span>请输入新密码:</span><input type="text" minlength="8" maxlength="16" v-model="newpassword"></div>
        <div><input class="submit-input" type="submit" value="确认更改" @click="changepassword"></div>
    </div>
</template>

<script>
    import {changepassword} from "../../../network/profile";

    export default {
        name: "ChangePassword",
        data() {
            return {
                oldpassword: '',
                newpassword: ''
            }
        },
        methods: {
            changepassword() {
                changepassword({
                    oldpassword: this.oldpassword,
                    newpassword: this.newpassword,
                }).then(res=>{
                    if(res.data.res_code === 2) {
                        alert('更改成功，请尽快重新登录！')
                    }else {
                        alert("服务器繁忙，请稍后再试！")
                    }
                })
            }
        }
    }
</script>

<style scoped>
    .changepass > * {
        height: 35px;
        line-height: 35px;
    }
    .changepass div {
        background-color: #f9f9f9;
        margin: 5px 0;
    }
    .submit-input {
        margin-left: 100px;
    }
</style>